package com.infoland.afanmall.model.my.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatEditText;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.StatusBarKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.my.adapter.KeFuAdapter;
import com.infoland.afanmall.model.my.entity.KefuEntity;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author 王永吉
 * @date 2018/7/23 10:47
 * 客服中心
 */
public class KeFuActivity extends AppCompatActivity {

    @BindView(R.id.recycler)
    RecyclerView recycler;
    @BindView(R.id.refresh_layout)
    SmartRefreshLayout refreshLayout;
    @BindView(R.id.title_layout)
    LinearLayout titleLayout;
    @BindView(R.id.bottom)
    LinearLayout bottom;
    @BindView(R.id.message)
    AppCompatEditText message;
    KeFuAdapter keFuAdapter;
    ArrayList<MultiItemEntity> arrayList;

    private int getLayout() {
        return R.layout.ke_fu_activity;
    }

    private void initData() {
        recycler.setLayoutManager(new LinearLayoutManager(this));
        arrayList = new ArrayList<>();
        arrayList.add(new KefuEntity(0));
        arrayList.add(new KefuEntity(1));
        arrayList.add(new KefuEntity(2));
        arrayList.add(new KefuEntity(0));
        arrayList.add(new KefuEntity(1));
        arrayList.add(new KefuEntity(2));
        initAdapter();
    }

    public void initAdapter() {
        keFuAdapter = new KeFuAdapter(arrayList);
        recycler.setAdapter(keFuAdapter);
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        ButterKnife.bind(this);
//        message.clearFocus();
        StatusBarKit.immersiveBlackTitleText(this);
        initData();
    }


    @OnClick({R.id.back, R.id.title_layout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                ToolsKit.goCloseDh(this);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        ToolsKit.deleteOKHttp(this);
        super.onDestroy();
    }

    @Override
    public void onBackPressed() {
        finish();
        ToolsKit.goCloseDh(this);
    }
}
